<template>
	
	<view class="container">
		<uni-section title="基本用法" type="line">
			<view class="example">
				<!-- 基础用法，不包含校验规则 -->
				<uni-forms ref="baseForm" :model="form" labelWidth="80px">
					<uni-forms-item label="日期">
						<uni-datetime-picker type="date" return-type="date"
							v-model="form.tradeDate" />
					</uni-forms-item>
					
					<uni-forms-item label="成交额">
						<uni-easyinput v-model="form.turnover" placeholder="请输入" />
					</uni-forms-item>
					
					<uni-forms-item label="大盘">
						<uni-easyinput v-model="form.shSzNetInflow" placeholder="请输入" />
					</uni-forms-item>
					<uni-forms-item label="沪深">
						<uni-easyinput v-model="form.hkNetInflow" placeholder="请输入" />
					</uni-forms-item>
					<uni-forms-item label="上涨">
						<uni-easyinput v-model="form.riseNum" placeholder="请输入" />
					</uni-forms-item>
					<uni-forms-item label="下跌">
						<uni-easyinput v-model="form.fallNum" placeholder="请输入" />
					</uni-forms-item>
					<uni-forms-item label="涨停">
						<uni-easyinput v-model="form.riseStopNum" placeholder="请输入" />
					</uni-forms-item>
					<uni-forms-item label="跌停">
						<uni-easyinput v-model="form.fallStopNum" placeholder="请输入" />
					</uni-forms-item>
				</uni-forms>
				<view class="button-group">
					<button type="primary" size="mini" @click="formReset()">重置</button>
					<button type="primary" size="mini" @click="formSubmit('valiForm')">提交</button>
				</view>
			</view>
		</uni-section>
	</view>
</template>
<script>
	import graceChecker from "../../../common/graceChecker.js"
	import {
		updateStockRiseFallNum
	} from "@/api/eye/stockRiseFallNum"
	export default {
		onLoad: function(option) { //option为object类型，会序列化上个页面传递的参数
			console.log('页面onLoad')
			// console.log('上一个页面的传参:' + JSON.stringify(option))
			this.form = option
			let pages = getCurrentPages();
		},
		onUnload() {
			console.log('页面onUnload')
		},
		data() {
			return {
				// 表单参数
				form: {}
			}
		},
		methods: {
			formSubmit: function(e) {
				updateStockRiseFallNum(this.form).then(res => {
					let pages = getCurrentPages();
					if (pages.length > 1) {
						console.log('获取上一页')
						let beforePage = pages[pages.length - 2]
						beforePage.$vm._data.refreshFlag = true
					}
					uni.showToast({
						title: "更新成功!",
						icon: "none"
					});
					setTimeout(() => {
						uni.navigateBack();
					}, 2000)
				})
			},
			formReset: function(e) {
				this.form = {}
				console.log('清空数据')
			}
		}
	}
</script>

<style lang="scss">
	.example {
		padding: 15px;
		background-color: #fff;
	}

	.segmented-control {
		margin-bottom: 15px;
	}

	.button-group {
		margin-top: 15px;
		display: flex;
		justify-content: space-around;
	}

	.form-item {
		display: flex;
		align-items: center;
		flex: 1;
	}

	.button {
		display: flex;
		align-items: center;
		height: 35px;
		line-height: 35px;
		margin-left: 10px;
	}
</style>
